#!/bin/bash
echo "添加用户"
echo -n "设定新用户用户名"
read USERNAME
echo -n "设定密码"
read PASSWORD
echo "正在添加用户"
echo "$USERNAME  ALL=(ALL:ALL) ALL" >> /etc/sudoers
if id -u "$USERNAME" > /dev/null 2>&1; then
	userdel -r -f $USERNAME
	useradd -m -p $PASSWORD -s /bin/bash $USERNAME
	usermod -a -G sudo $USERNAME
	echo $USERNAME:$PASSWORD | chpasswd
else
	useradd -m -p $PASSWORD -s /bin/bash $USERNAME
	usermod -a -G sudo $USERNAME
	echo $USERNAME:$PASSWORD | chpasswd
fi
echo "输入su $USERNMAE切换用户"